/*
db table 定义

*/

#pragma once

#include <string>
#include <vector>
#include "dbTable.h"
#include "dbStructDef.h"
#include "ProtoMarco.h"
#include "dbTable.h"

using namespace proto;
namespace proto
{
	//服务器全局存库. 类型 关联 自定义数据
	//例如： 开服 --开服信息
	//		排行榜1-- 排行榜信息
	//		活动1 --活动信息
	const static uint16_t GLOBAL_TABLE_ID = 1;
	struct DbGlobalData : public BaseTable
	{
		DbGlobalData() : BaseTable(GLOBAL_TABLE_ID) {}
		uint64_t id = 0; //存库id 对应 GlobalType 类型
		std::string serial;//自定义数据
	};

	const static uint16_t ACC_TABLE_ID = 2;
	struct DbAcc : public BaseTable
	{
		DbAcc() : BaseTable(ACC_TABLE_ID) {}
		std::string name;
		std::string psw;
		std::vector<PlayerBrief> vecPlayer; //角色列表
	};

	const static uint16_t PLAYER_TABLE_ID = 3;
	struct DbPlayer : public BaseTable
	{
		DbPlayer() : BaseTable(PLAYER_TABLE_ID) {}
		uint64_t id = 0;//角色id
		std::string name;
		std::string accName;
		DbScene scene;
	};

	const static uint16_t RELA_TABLE_ID = 4;
	struct DbRelaPlayer : public BaseTable
	{
		DbRelaPlayer() : BaseTable(RELA_TABLE_ID) {}
		uint64_t id = 0; //角色id
		DbFriendBrief brief; //自身信息
		std::vector<uint64_t> vecFriend;
		std::vector<uint64_t> vecApplicant;
		std::vector<uint64_t> vecBlacklist;
	};

	const static uint16_t MAIL_BOX_TABLE_ID = 5;
	struct DbMailBox : public BaseTable
	{
		DbMailBox() : BaseTable(MAIL_BOX_TABLE_ID) {}
		uint64_t id = 0; //角色id
		uint64 lastSysMailId = 0;  //已处理接收系统广播邮件id. 新号初始化为最大系统广播邮件id
		std::unordered_map<uint64, DbMail> id2Mail;
	};

	//公会
	const static uint16_t UNION_TABLE_ID = 6;
	struct DbUnion : public BaseTable
	{
		DbUnion() : BaseTable(UNION_TABLE_ID) {}
		uint64_t id = 0; 
		std::string name;
		DbFriendBrief owner; //会长
		std::unordered_map<uint64, DbUnionMem> id2Member;
	};

//先定义宏参数信息，以后再具体实现
//域的顺序 和 遗漏，都会初始化的时候检查出来
#define DB_ALL_TABLE_INFO \
	DB_CLASS_NAME(DbGlobalData)\
	DB_MAIN_KEY(id)\
	DB_FIELD(serial)\
	DB_CLASS_END\
	\
	DB_CLASS_NAME(DbAcc)\
	DB_MAIN_KEY(name)\
	DB_FIELD(psw)\
	DB_FIELD(vecPlayer)\
	DB_CLASS_END\
\
	DB_CLASS_NAME(DbPlayer)\
	DB_MAIN_KEY(id)\
	DB_INDEX_KEY(name)\
	DB_FIELD(accName)\
	DB_FIELD(scene)\
	DB_CLASS_END\
\
	DB_CLASS_NAME(DbRelaPlayer)\
	DB_MAIN_KEY(id)\
	DB_FIELD(brief)\
	DB_FIELD(vecFriend)\
	DB_FIELD(vecApplicant)\
	DB_FIELD(vecBlacklist)\
	DB_CLASS_END\
\
	DB_CLASS_NAME(DbMailBox)\
	DB_MAIN_KEY(id)\
	DB_FIELD(lastSysMailId)\
	DB_FIELD(id2Mail)\
	DB_CLASS_END\
\
	DB_CLASS_NAME(DbUnion)\
	DB_MAIN_KEY(id)\
	DB_FIELD(name)\
	DB_FIELD(owner)\
	DB_FIELD(id2Member)\
	DB_CLASS_END\

//其中具体实现例子，这里为空实现 给你参考
#define DB_CLASS_NAME(className)	 
#define DB_MAIN_KEY(fieldName)	 
#define DB_INDEX_KEY(fieldName)	
#define DB_FIELD(fieldName)	 
#define DB_CLASS_END		

	DB_ALL_TABLE_INFO

#undef  DB_CLASS_NAME
#undef  DB_MAIN_KEY
#undef  DB_INDEX_KEY
#undef  DB_FIELD
#undef  DB_CLASS_END



}